<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/5/27
 * Time: 21:37
 */

namespace app\common\enum;


use app\models\Option;
use yii\helpers\ArrayHelper;

class OptionEnum extends BaseEnum
{
    const XBGL_GW = 'XBGL_GW';

    public static function getOptionValue($value , $default = ''){
        $row = Option::find()->andWhere(['key' => $value])->one();
        return ArrayHelper::getValue($row,"value",$default);
    }

    public static function setOptionValue($value , $value_data){
        $row = Option::find()->andWhere(['key' => $value])->one();
        if(! $row instanceof Option){
            $row = new Option();
            $row->key = $value;
        }
        $row->value = $value_data;
        return $row->save();
    }
}